{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 第一题：决策树处理分类任务"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1.\t使用sklearn.tree.DecisionTreeClassifier完成dota2比赛结果预测问题\n",
    "2.\t计算最大深度为10时，十折交叉验证的精度(accuracy)，查准率(precision)，查全率(recall)，F1值\n",
    "3.\t绘制最大深度从1到10的决策树十折交叉验证精度的变化图"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1. 读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "dota2results = np.loadtxt('data/dota2Dataset/dota2Train.csv', delimiter=',')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "dota2x = dota2results[:, 1:]\n",
    "dota2y = dota2results[:, 0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2. 导入模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.model_selection import cross_val_predict\n",
    "from sklearn.metrics import accuracy_score\n",
    "from sklearn.metrics import precision_score\n",
    "from sklearn.metrics import recall_score\n",
    "from sklearn.metrics import f1_score\n",
    "from sklearn.tree import DecisionTreeClassifier\n",
    "\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from sklearn.model_selection import train_test_split, cross_val_score\n",
    "from sklearn.feature_extraction.text import TfidfVectorizer\n",
    "from matplotlib.font_manager import FontProperties"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3. 训练与预测\n",
    "计算最大深度为10的决策树，在使用数据dota2x，标记dota2y下，十折交叉验证的精度，查准率，查全率和F1值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "决策树在dota2测试集上的四项指标\n",
      "精度: 0.5506853750674582\n",
      "查准率: 0.5566861616978112\n",
      "查全率: 0.7199991800254192\n",
      "f1值: 0.6278972067039107\n"
     ]
    }
   ],
   "source": [
    "model = DecisionTreeClassifier(max_depth = 10) # 参数max_depth决定了决策树的最大深度\n",
    "# YOUR CODE HERE\n",
    "\n",
    "prediction = cross_val_predict(model,dota2x,dota2y,cv = 10)\n",
    " \n",
    "acc1 = accuracy_score(dota2y,prediction)\n",
    "precision1 = precision_score(dota2y,prediction)\n",
    "recall1 = recall_score(dota2y,prediction)\n",
    "f1 = f1_score(dota2y,prediction)\n",
    "\n",
    "print(\"决策树在dota2测试集上的四项指标\")\n",
    "print(\"精度:\",acc1)\n",
    "print(\"查准率:\",precision1)\n",
    "print(\"查全率:\",recall1)\n",
    "print(\"f1值:\",f1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###### 双击此处填写下面的表格\n",
    "\n",
    "最大深度为10：  \n",
    "\n",
    "精度 | 查准率 | 查全率 | F1\n",
    "- | - | - | -\n",
    "0.550523475445224 | 0.5565538442035876 | 0.7199991800254192 | 0.6278130306551077"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4. 改变最大深度，绘制决策树的精度变换图"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "绘制最大深度从1到10，决策树十折交叉验证精度的变化图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, 'accuracy_score')"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUg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rbTRtLbYR0PAUooO0PSl5ImSnpIUlaYvk7S7ZLGS3pXUrakE4AcoicOTJTUKKzm8jDfZEn903nMnEuFJxznStebqHOzXYH+wGnAfsAfgGuAb4H9w1OarwNuCcvdBfSWdBzwL+AiM8svYxvXAx+HdbwKdAWQtDNwMrCvmQ0BioDTwzJNgPFmtjswBrjezJ4HxgKnm9kQM9sQ5l0W5nsgxO1crPxZas6V7jszmwwgaQpRr4kmaTLQHWgBjJTUBzCgHoCZFUs6B/gaeMjMPilnG/sDx4fl3pC0Mkw/GNgD+Cp6DiWN+OEpv8XAs2H4CaKnIpelpGxcyXaci5MnHOdKtylhuDhhvJjoc3Mz8L6ZHRc6xvsgYf4+wDpSu6dS2sMMBYw0s6u3c/kSJTEX4Z91Vw14lZpz26cFsDAMn1MyUVILoqq4/YE24f5KWT4kVJVJ+hnQKkx/FzhBUrtQ1lpSt1BWByhZ52nAx2F4LdBsB/bHubTzhOPc9vk7cKukT4CshOl3Aveb2QzgfGBESeIoxY3A/pLGA4cRPT4eM5sK/Bl4W9LXwGigQ1hmPTBQ0jjgIOCmMP3fwINJjQacq1a8ewLnMoikdWbWNO44nNsefoXjnHOuSvgVjnNpJulc4IqkyZ+Y2aVxxONcXDzhOOecqxJepeacc65KeMJxzjlXJTzhOOecqxKecJxzzlWJ/w+qu2aBsbx8kwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# YOUR CODE HERE\n",
    "y = []\n",
    "\n",
    "for i in range(10):\n",
    "    model = DecisionTreeClassifier(max_depth = i + 1)\n",
    "    prediction = cross_val_predict(model,dota2x,dota2y,cv=10)\n",
    "    y.append(prediction)\n",
    "    \n",
    "x = np.linspace(1,10,10)\n",
    "test = [accuracy_score(dota2y, val) for val in y]\n",
    "\n",
    "plt.figure()\n",
    "plt.plot(x,test,'-')\n",
    "plt.title(\"DecisionTree's accuracy_score changes with the max_depth\")\n",
    "plt.xlabel(\"max_depth\")    \n",
    "plt.ylabel(\"accuracy_score\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 5. （选做）通过调整参数，得到一个泛化能力最好的模型"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "查看决策树文档，通过调整决策树的参数，得到一个最好的模型  \n",
    "http://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html#sklearn.tree.DecisionTreeClassifier  \n",
    "并在下方给出参数的设定与其泛化性能指标"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**（选做仅供参考）**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "使用的GridSearchCV，它存在的意义就是自动调参，只要把参数输进去，就能给出最优化的结果和参数。\n",
    "但是这个方法适合于小数据集，一旦数据的量级上去了，很难得出结果。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# YOUR CODE HERE\n",
    "from sklearn.model_selection import GridSearchCV\n",
    "from sklearn.model_selection import StratifiedKFold\n",
    "modelfit = DecisionTreeClassifier(max_depth = 10)\n",
    "param_grid = {'criterion':['gini','entropy'],'max_depth':[10,11,12],\n",
    "                  'min_samples_leaf':[1,2,3,4,5],'max_features':[1,2,3,4,5],'min_samples_split':[2,3,4,5]}\n",
    "\n",
    "grid = GridSearchCV(modelfit,param_grid,cv = 10)\n",
    "\n",
    "grid.fit(dota2x,dota2y)\n",
    "\n",
    "best = grid.best_params_  #最优分类器\n",
    "print(best)\n",
    "best_decision_tree_classifier = DecisionTreeClassifier(max_depth = best['max_depth'],max_features=best['max_features'],\n",
    "                                                       min_samples_leaf = best['min_samples_leaf'],min_samples_split = best['min_samples_split'])\n",
    "prediction = cross_val_predict(best_decision_tree_classifier,dota2x,dota2y,cv = 10)\n",
    "\n",
    "acc1 = accuracy_score(prediction,dota2y)\n",
    "precision1 = precision_score(dota2y,prediction)\n",
    "recall1 = recall_score(dota2y,prediction)\n",
    "f1 = f1_score(dota2y,prediction)\n",
    "\n",
    "print(\"优化后的决策树在dota2测试集上的四项指标\")\n",
    "print(\"精度:\",acc1)\n",
    "print(\"查准率:\",precision1)\n",
    "print(\"查全率:\",recall1)\n",
    "print(\"f1值:\",f1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###### 双击此处填写参数设置与性能指标的结果\n",
    "\n",
    "参数设置：  min_samples_leaf': 2, 'max_depth': 12, 'criterion': 'entropy', 'min_samples_split': 4, 'max_features': 5\n",
    "\n",
    "\n",
    "性能指标得分：\n",
    "精度: 0.5372908796546141\n",
    "查准率: 0.5417502330442643\n",
    "查全率: 0.7862941248821287\n",
    "f1值: 0.641507225046829"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
